package com.future.admin.controller;

import com.future.admin.service.SysUserService;
import com.future.common.api.auth.StatusUser;
import com.future.common.api.result.R;
import com.future.common.security.annoation.Ignore;
import com.future.common.security.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: liuby5
 * @CreateTime: 2023-05-08  14:25
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/sys-user")
@Slf4j
public class SysUserController {
    @Resource
    private SysUserService sysUserService;


    /**
     * 用户登录信息
     *
     * @param username
     * @return
     */
    @GetMapping("/info/{username}")
    @Ignore
    public R getInfo(@PathVariable("username") String username) {
        return sysUserService.getLoginUser(username);
    }


    @GetMapping("/info/security")
    public R getSecurityInfo() {
        StatusUser user = SecurityUtils.getUser();
        return R.ok(user);
    }

    @Ignore
    @GetMapping("/create-code")
    public R getCode() {
        return sysUserService.createCode();
    }


    @GetMapping("/login-user-info")
    public R getLoginUser(){
        return sysUserService.getUserInfo();
    }

}
